<script lang="ts" setup>
import { computed, unref } from 'vue'
import SettingDrawer from './SettingDrawer.vue'
import { Icon } from '@/components/Icon'

import { useDrawer } from '@/components/Drawer'
import { useRootSetting } from '@/hooks/setting/useRootSetting'
import { SettingButtonPositionEnum } from '@/enums/appEnum'

defineOptions({ name: 'SettingButton' })
const { getShowSettingButton, getSettingButtonPosition } = useRootSetting()
const [register, { openDrawer }] = useDrawer()

const show = computed(() => {
  return (
    unref(getShowSettingButton)
    && unref(getSettingButtonPosition) == SettingButtonPositionEnum.FIXED
  )
})
</script>

<template>
  <div v-if="show" @click="openDrawer(true)">
    <Icon icon="ion:settings-outline" />
    <SettingDrawer @register="register" />
  </div>
</template>
